package com.artisan.booteventbus.dao;

import com.artisan.booteventbus.domain.MessageEvent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

@Slf4j
@Repository
public class MessageRepository {

    private final List<MessageEvent> messageStore = new ArrayList<>();

    public void save(MessageEvent event) {
        // 模拟存储
        messageStore.add(event);
        System.out.println(Thread.currentThread().getName() + " - Message saved: " + event.getMessage());
        log.info("Message saved {}", event.getMessage());
    }
}
